package yang.model;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * HospitalDrug entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "hospital_drug", catalog = "hospital")
public class HospitalDrug implements java.io.Serializable {

	// Fields

	private String id;//UUID
	private DrugType drugType;//关联的药品类型
	private String drugName;//药品名称
	private Double drugPrice;//价格
	private String drugUnit;//药品字典
	private Set<ChufangItmes> chufangItmeses = new HashSet<ChufangItmes>(0);

	// Constructors

	/** default constructor */
	public HospitalDrug() {
	}

	/** minimal constructor */
	public HospitalDrug(String id) {
		this.id = id;
	}

	/** full constructor */
	public HospitalDrug(String id, DrugType drugType, String drugName,
			Double drugPrice, String drugUnit, Set<ChufangItmes> chufangItmeses) {
		this.id = id;
		this.drugType = drugType;
		this.drugName = drugName;
		this.drugPrice = drugPrice;
		this.drugUnit = drugUnit;
		this.chufangItmeses = chufangItmeses;
	}

	// Property accessors
	@Id
	@Column(name = "id", unique = true, nullable = false, length = 36)
	public String getId() {
		return this.id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "drug_type_id")
	public DrugType getDrugType() {
		return this.drugType;
	}

	public void setDrugType(DrugType drugType) {
		this.drugType = drugType;
	}

	@Column(name = "drug_name")
	public String getDrugName() {
		return this.drugName;
	}

	public void setDrugName(String drugName) {
		this.drugName = drugName;
	}

	@Column(name = "drug_price", precision = 22, scale = 0)
	public Double getDrugPrice() {
		return this.drugPrice;
	}

	public void setDrugPrice(Double drugPrice) {
		this.drugPrice = drugPrice;
	}

	@Column(name = "drug_unit", length = 10)
	public String getDrugUnit() {
		return this.drugUnit;
	}

	public void setDrugUnit(String drugUnit) {
		this.drugUnit = drugUnit;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "hospitalDrug")
	public Set<ChufangItmes> getChufangItmeses() {
		return this.chufangItmeses;
	}

	public void setChufangItmeses(Set<ChufangItmes> chufangItmeses) {
		this.chufangItmeses = chufangItmeses;
	}

}